<?php
/**
 * Created by JetBrains PhpStorm.
 * User: thanh
 * Date: 4/8/12
 * Time: 4:12 PM
 * To change this template use File | Settings | File Templates.
 */
class ResetpwForm extends CFormModel
{

    public $email;
    public function rules(){
        return array(
            array('email','required'),
            array('email','email'),
            array('email','checkEmail'),
        );
    }

    /**
     * Authenticates the email
     * @param $attribute
     * @param $params
     */
    public function checkEmail($attribute, $params)
    {
        $user = User::model()->find('LOWER(email=?)', array(strtolower($this->email)));
        if ($user === null) {
            $this->addError('email', 'Email không tồn tại.');
        }
    }
}
